#ifndef TD_PROGRESS_BAR_H_
#define TD_PROGRESS_BAR_H_

/************************************************************************/
/* SDL                                                                  */
/************************************************************************/
#include "SDL/SDL.h"

/************************************************************************/
/* PROJECT                                                              */
/************************************************************************/

/************************************************************************/
/* Core                                                                 */
/************************************************************************/
#include "Core/BaseEntity.h"
#include "Core/RectangleShape.h"

using namespace TD_Core;

namespace TD_GUI {

	class ProgressBar : public BaseEntity {

		/************************************************************************/
		/* Default definitions                                                  */
		/************************************************************************/
		static const unsigned int backgroundOffset;
		static const float defaultProgressSpeed;
		
		/************************************************************************/
		/* Private members                                                      */
		/************************************************************************/
		Color m_foregroundColor;
		Color m_backgroundColor;
		SDL_Rect m_backgroundRect;
		SDL_Rect m_foregroundRect;

		/**Error keeping float*/
		float m_error;
		float m_progressSpeed;

		/**Progress bar size*/
		Coord2D m_size;

		bool m_isFull;

		void update(const unsigned int deltaTime);

	public:
		
		/************************************************************************/
		/* ctors and dtors					                                    */
		/************************************************************************/
		//Default constructor
		explicit ProgressBar();

		//Copy constructor
		explicit ProgressBar(const ProgressBar &rhs);

		//Assignment constructor
		ProgressBar& operator=(const ProgressBar &rhs);

		//Initialization constructor
		explicit ProgressBar(const Coord2D & barPosition, const Coord2D & barSize, float progressSpeed = defaultProgressSpeed,
								Color foregroundColor = Color::GREEN, Color backgroundColor = Color::BLACK);

		//Destructor
		~ProgressBar();

		/************************************************************************/
		/* Access functions                                                     */
		/************************************************************************/
		inline bool isFull() const {
			return(m_isFull);
		}

		inline void setSpeed(float progressSpeed) {
			m_progressSpeed = progressSpeed;
		}

		void restartProgress();


		void render(SDL_Surface *const g_destSurface, unsigned int deltaTime);

	};
}
#endif